mod sliding_box;

use ggez::{Context, GameResult, GameError, graphics};

pub struct State{
    slidings: Vec<sliding_box::SlidingBox>,
}

impl State{
    pub fn new() -> State {
        let mut slidings: Vec<sliding_box::SlidingBox> = vec![];
        for _i in 0..1 {
            let sliding_box = sliding_box::SlidingBox::new();
            slidings.push(sliding_box);
        }
        State { slidings }
    }
}

impl ggez::event::EventHandler<GameError> for State {
    fn update(&mut self, ctx: &mut Context) -> GameResult {
        for sliding_box in &mut self.slidings {sliding_box.update(ctx)}
        Ok(())
    }
    fn draw(&mut self, ctx: &mut Context) -> GameResult {
        let mut canvas = graphics::Canvas::from_frame(ctx, graphics::Color::WHITE);
        for sliding_box in &mut self.slidings {sliding_box.display(ctx, &mut canvas)}
        canvas.finish(ctx)?;
        Ok(())
    }
}